package com.bargetor.migrant.web.root

import org.springframework.core.annotation.Order
import org.springframework.web.WebApplicationInitializer
import org.springframework.web.context.ContextLoaderListener
import org.springframework.web.util.Log4jConfigListener
import javax.servlet.ServletContext
import javax.servlet.ServletException

/**
 * Created by bargetor on 2017/7/1.
 */

@Order(1)
class SpringContextInitializer : WebApplicationInitializer {
    @Throws(ServletException::class)
    override fun onStartup(servletContext: ServletContext) {
        //log4j
        servletContext.setInitParameter("log4jConfigLocation", "classpath:log4j.properties")
        servletContext.setInitParameter("log4jRefreshInterval", "60000")
        servletContext.addListener(Log4jConfigListener::class.java)

        servletContext.setInitParameter("contextConfigLocation", "classpath:*-application-context*.xml")
        servletContext.addListener(ContextLoaderListener::class.java)
    }
}